package com.rfid.afd.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;

import com.rfid.afd.activity.view.ILocateView;
import com.rfid.afd.presenter.LocatePresenter;
import com.rfid.db.bean.Operation;
import com.rfid.db.bean.Rfid;

import java.util.List;
/**定位，流程与盘点一样，唯一不同的是盘点到错架的书籍后把错架的书籍所属的层标修改为当前层架*/
public class LocateActivity extends BaseCommonUiActivity<LocatePresenter> implements ILocateView {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mCheckTitle.setText("已定位：");
    }

    @Override
    public LocatePresenter getPresenter() {
        return new LocatePresenter();
    }

    @Override
    public void onScaned(String code,Rfid rfid) {
        super.onScaned(code,rfid);
        if(rfid.getId() != null)
            mPresenter.addOperationLog(rfid, Operation.OPERATE_LOCATE);
    }

    @Override
    protected void onShelfGot(String shelf) {
        mPresenter.getLocatedData(mShelf);
    }

    @Override
    protected void onErrorShelf(Rfid rfid) {
        if(rfid.getId() != null)
            mPresenter.locate(mShelf,rfid);
    }

    @Override
    public void onRfidsQueryedByShelf(List<Rfid> rfids) {
        updateData(rfids);
    }

}